/*
 * MacHeader.h
 *
 *  Created on: Oct 9, 2008
 *      Author: lc6
 */
#include "iu_wiretap.h"
#ifndef MACHEADER_H_
#define MACHEADER_H_
#include "../tests/MacHeaderTest.h"

/* ethernet headers are always exactly 14 bytes [1] */
#define SIZE_ETHERNET 14

/* Ethernet addresses are 6 bytes */
#define ETHER_ADDR_LEN  6

/* Ethernet Type*/
#define IP_INSIDE 0x0800
#define ARP_INSIDE 0x0806

/* Ethernet header */
struct SniffEthernet
{
  u_char etherDhost[ETHER_ADDR_LEN]; /* destination host address */
  u_char etherShost[ETHER_ADDR_LEN]; /* source host address */
  u_short etherType; /* IP? ARP? RARP? etc */
};

using namespace std;

class MacHeader
{
public:

  /**
     Constructor for Mac Header
        \param address is the mac address of ethernet packet
  */
  friend class MacHeaderTest;
  MacHeader(string address);
  MacHeader();
  MacHeader(const MacHeader &Header);
  /**
    * Packet handler for Ethernet Header
    * \param packet is a pointer for the whole packet
    * \param index is a index which indicate start of ethernet header
    * \return next protocol
    */
  static Protocol
   handlePacket(const u_char * packet, int& index);
  string printRecord();
  virtual
  ~MacHeader();
  static string showAll();
private:
  static int nBroadcast;
  string address_;
  static string rawMacToString(const u_char * start );
  void increaseRecvPacketCounter(int n);
  void increaseSendPacketCounter();
  static map<string,MacHeader*> macHeaderMap_;
  int nRecvPacket_;
  int nSendPacket_;
  int PacketNo_;

};


#endif /* MACHEADER_H_ */
